package com.gtxc.kotlinmvvm.ui.activity

import android.content.Intent
import android.os.Bundle
import android.util.Log
import com.aleyn.mvvm.base.BaseActivity
import com.blankj.utilcode.util.ToastUtils
import com.gtxc.kotlinmvvm.BR
import com.gtxc.kotlinmvvm.R
import com.gtxc.kotlinmvvm.databinding.AcitivityForgetPasswordBinding
import com.gtxc.kotlinmvvm.network.request.ForgetBean
import com.gtxc.kotlinmvvm.network.request.RegisterBean
import com.gtxc.kotlinmvvm.utlis.setOnclickNoRepeat
import com.gtxc.kotlinmvvm.viewmodle.ForgetPasswordViewModle
import kotlinx.android.synthetic.main.acitivity_forget_password.*

/**
 * FileName:ForgetPasswordActivity
 * Author：Administrator
 * Date:2021 2021/9/29 15:14
 * Copyright (C), 2020-2021,成都拇音科技有限公司
 *
 *
 *
 *
 * Description: 忘记密码
 * History:
 * <author> <time> <version> <desc>
 * 作者姓名 修改时间 版本号 描述
</desc></version></time></author> */
//忘记密码
class ForgetPasswordActivity : BaseActivity<ForgetPasswordViewModle, AcitivityForgetPasswordBinding>() {
    override fun layoutId(): Int {
        return R.layout.acitivity_forget_password
    }

    override fun initView(savedInstanceState: Bundle?) {}
    override fun initData() {

    }
    override fun initCLick() {
        setOnclickNoRepeat(mBinding?.xiayibuBut ){
            when(it.id){
                R.id.xiayibu_but -> {
                    when {
                        mBinding?.ed04?.text.toString().isEmpty() -> ToastUtils.showLong("手机号不能为空")
                        mBinding?.ed06?.text.toString().isEmpty() -> ToastUtils.showLong("验证码不能为空")
                        mBinding?.ed5?.text.toString().isEmpty() -> ToastUtils.showLong("密码不能为空")
                        mBinding?.ed9?.text.toString().isEmpty() -> ToastUtils.showLong("请确认密码")
                        else -> viewModel.modificationpass(ForgetBean( mBinding?.ed9?.text.toString(),mBinding?.ed04?.text.toString(),mBinding?.ed5?.text.toString(), mBinding?.ed06?.text.toString()))
                    }
                }
            }
        }

        viewModel.ok.observe(this, {
            Log.e("TAccccG", "onChanged: 数据有更新"+it)
            if (it){
                startActivity(Intent(this, ForgetPasswordActivity::class.java))
                finish()
            }
        })
    }
    override fun variableID(): Int {
        return BR.forgetPpasswordModels
    }

    override fun bindViewModel() {}
}